package com.fulin.leetcode.dijkstra;

import org.springframework.aop.target.LazyInitTargetSource;

import java.util.LinkedList;

/**
 * TODO
 *
 * @Author fulin
 * @Date 2022/7/7 10:06
 **/
public class Graph {
    private LinkedList<Edge> adj[]; //邻接表
    private int v;//顶点个数

    public Graph(int v){
        this.v = v;
        this.adj = new LinkedList[v];
        for(int i = 0; i < v;i++){
            this.adj[i] = new LinkedList<>();
        }
    }

    public void addEdge(int s,int t,int w){
        this.adj[s].add(new Edge(s,t,w));
    }

    private class Vertex{
        public int id;  //定点编号
        public int dist;//从起始定点到这个顶点的距离

        public Vertex(int id, int dist) {
            this.id = id;
            this.dist = dist;
        }
    }



    //图的边
    private class Edge{
        public int sid; //边的起始端点
        public int tid; //边的终止端点
        public int w;   //权重

        public Edge(int sid, int tid, int w) {
            this.sid = sid;
            this.tid = tid;
            this.w = w;
        }
    }
}
